"""
@File    :   validate.py
@Time    :   2024/04/13 16:40:28
@Author  :   Qrj
@Email   :   923207736@qq.com
@description   :   字典类型相关的pydantic验证模型
"""


from datetime import datetime

from pydantic import BaseModel, Field, conint

from src.schemas.validate import (
    BaseSearchValidateSchemaMixin,
    BaseValidateSchemaConfigMixin,
)


class DictTypeCreateValidateSchema(BaseModel, BaseValidateSchemaConfigMixin):
    """用于创建字典类型的验证模型"""

    name: str = Field(default=..., min_length=1, max_length=100, description="字典名称")
    type: str = Field(default=..., min_length=1, max_length=100, description="字典类型")
    status: bool = Field(default=True, description="状态")
    remark: str = Field(default="", min_length=1, max_length=300, description="备注")
    show_order: int = Field(default=1, ge=1, le=9999999, description="显示顺序")


class DictTypeUpdateValidateSchema(BaseModel, BaseValidateSchemaConfigMixin):
    """用于修改字典类型的验证模型"""

    id: int = Field(default=..., ge=1, description="主键")
    name: str = Field(default=..., min_length=1, max_length=100, description="字典名称")
    status: bool = Field(default=True, description="状态")
    remark: str = Field(default="", min_length=1, max_length=300, description="备注")
    show_order: int = Field(default=1, ge=1, le=9999999, description="显示顺序")


class DictTypeUpdateStatusValidateSchema(BaseModel, BaseValidateSchemaConfigMixin):
    """用于单独修改字典类型的状态的验证模型"""

    id: int = Field(default=..., ge=1, description="主键")
    status: bool = Field(default=..., description="状态")


class DictTypeDeleteValidateSchema(BaseModel, BaseValidateSchemaConfigMixin):
    """用于删除字典类型的验证模型"""

    ids: list[conint(ge=1)] = Field(
        default=..., min_length=1, description="需删除的主键列表"
    )


class DictTypeListSearchValidateSchema(BaseModel, BaseSearchValidateSchemaMixin):
    """用于查询租户套餐列表的验证模型"""

    name: str | None = Field(
        default=None,
        min_length=1,
        max_length=100,
        description="字典名称",
        json_schema_extra={"str_like_search_type": "complete"},
    )
    type: str | None = Field(
        default=None,
        min_length=1,
        max_length=100,
        description="字典类型",
        json_schema_extra={"str_like_search_type": "complete"},
    )
    status: bool | None = Field(default=None, description="状态")
    remark: str | None = Field(
        default=None,
        min_length=1,
        max_length=300,
        description="备注",
        json_schema_extra={"str_like_search_type": "complete"},
    )
    create_datetime: tuple[datetime, datetime] | None = Field(
        default=None,
        description="创建时间",
        json_schema_extra={"allow_order": True},
    )
    update_datetime: tuple[datetime, datetime] | None = Field(
        default=None,
        description="修改时间",
        json_schema_extra={"allow_order": True},
    )
    creator_username: str | None = Field(
        default=None,
        min_length=1,
        max_length=20,
        description="创建者用户名",
        json_schema_extra={"str_like_search_type": "complete"},
    )
    updater_username: str | None = Field(
        default=None,
        min_length=1,
        max_length=20,
        description="修改者用户名",
        json_schema_extra={"str_like_search_type": "complete"},
    )
